<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改影视管理')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-film-edit" th:object="${dsFilm}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label">年度：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="annual" th:value="${#dates.format(dsFilm.annual, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" >
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">影视名称：</label>
                <div class="col-sm-8">
                    <input name="tvSeries" th:field="*{tvSeries}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">海报图：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="img" th:field="*{img}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="img" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">剧情简介：</label>
                <div class="col-sm-8">
                    <textarea name="topicContent" class="form-control">[[*{topicContent}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">影视类型：</label>
                <div class="col-sm-8" th:with="type=${@dict.getType('ds_film_type')}">
                    <!-- 把 dsFilm.type 拆分成列表 -->
                    <label th:each="dict : ${type}" class="check-box">
                        <input name="type" type="checkbox"
                               th:value="${dict.dictValue}"
                               th:text="${dict.dictLabel}"
                               th:checked="${dsFilm.type != null and dsFilm.type.contains(',' + dict.dictValue + ',') or
                                dsFilm.type == dict.dictValue}" />
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">导演：</label>
                <div class="col-sm-8">
                    <input name="director" th:field="*{director}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">编剧：</label>
                <div class="col-sm-8">
                    <input name="screenwriter" th:field="*{screenwriter}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">主要演员：</label>
                <div class="col-sm-8">
                    <input name="actor" th:field="*{actor}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">集数：</label>
                <div class="col-sm-8">
                    <input name="episodeNum" th:field="*{episodeNum}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">提名理由：</label>
                <div class="col-sm-8">
                    <input name="reasons" th:field="*{reasons}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">年代划分：</label>
                <div class="col-sm-8">
                    <select name="chronologicalDivision" class="form-control m-b" th:with="type=${@dict.getType('ds_history')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{chronologicalDivision}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">链接：</label>
                <div class="col-sm-8">
                    <input name="url" th:field="*{url}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">影视分类：</label>
                <div class="col-sm-8">
                    <select name="kind" class="form-control m-b" th:with="type=${@dict.getType('ds_kind')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{kind}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">是否推荐：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('ds_film_recommend')}">
                        <input type="radio" th:id="${'recommend_' + dict.dictCode}" name="recommend" th:value="${dict.dictValue}" th:field="*{recommend}" required>
                        <label th:for="${'recommend_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">获奖信息：</label>
                <div class="col-sm-8">
                    <input name="awardInformation" th:field="*{awardInformation}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">排序值：</label>
                <div class="col-sm-8">
                    <input name="sortNum" th:field="*{sortNum}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "front/film";
        $("#form-film-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-film-edit').serialize());
            }
        }

        $("input[name='annual']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
    </script>
</body>
</html>